package cn.itsource.pojo;

import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
public enum UserLevelMenu {
    BRONZE(0L,"青铜"),
    SILVER(1L,"白银"),
    GOLD(2L,"黄金"),
    PLATINUM(3L,"白金"),
    MASTER(4L,"大师"),
    GRANDMASTER(5L,"宗师"),
    KING(6L,"王者");

    private Long key;
    private String value;

    UserLevelMenu(Long key, String value) {
        this.key = key;
        this.value = value;
    }

    /**
     * 根据key获取UserLevelConst
     * @param key
     * @return
     */
    public UserLevelMenu getLevelByKey(Long key){
        UserLevelMenu[] values = UserLevelMenu.values();
        Optional<UserLevelMenu> any = Arrays.stream(values).filter(item -> item.key.equals(key)).findAny();
        return any.get();
    }
}
